package fun.qu_an.minecraft.mini_games_helper.client.mixin;

import fun.qu_an.minecraft.mini_games_helper.client.handle.ForceOptionHelperSodium;
import fun.qu_an.minecraft.mini_games_helper.client.handle.ForceOptionHelperVanilla;
import net.minecraft.client.network.ClientPlayerInteractionManager;
import net.minecraft.world.GameMode;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

@Mixin(ClientPlayerInteractionManager.class)
public class ClientPlayerInteractionManager_GameModeChangeListenerMixin {
	@Inject(method = "setGameMode(Lnet/minecraft/world/GameMode;)V",
		at = @At(value = "RETURN"))
	// mixin at return to make sure applied after gm change
	private void afterGMChange(GameMode gameMode, CallbackInfo ci) {
		ForceOptionHelperVanilla.apply(gameMode);
		ForceOptionHelperSodium.apply(gameMode);
	}
}
